package it.softphone.commons.json.server.jersey;


import it.softphone.commons.json.server.JSONUtils;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;


@SuppressWarnings("serial")
public class JSONExceptionMapper extends WebApplicationException {

	public JSONExceptionMapper() {
		super();
	}

	public JSONExceptionMapper(int status) {
		super(status);
	}

	public JSONExceptionMapper(Response response) {
		super(response);
	}

	public JSONExceptionMapper(Status status) {
		super(status);
	}

	public JSONExceptionMapper(Throwable cause, Response response) {
		super(cause, response);
	}

	public JSONExceptionMapper(Throwable cause) {
		this( cause, Status.INTERNAL_SERVER_ERROR);
	}

	public JSONExceptionMapper(Throwable cause, int status) {
		super(Response.status(status).entity( JSONUtils.toJSON(cause)).build());
	}

	public JSONExceptionMapper(Throwable cause, Status status) {
		super(Response.status(status).entity( JSONUtils.toJSON(cause)).build());
	}

	public JSONExceptionMapper(String cause) {
		this( new Exception(cause) );
	}

	public JSONExceptionMapper(String cause, int status) {
		this( new Exception(cause), status);
	}

	public JSONExceptionMapper(String cause, Status status) {
		this( new Exception(cause), status);
	}

}
